var Http = {};
// var rootUrl = "http://10.60.228.255:8080/springmvc_project/";
var rootUrl = "http://116.196.94.179:8080/projectMvc/";


function setHeader(xhr) {
    // xhr.setRequestHeader("openId", "o0HL0sgomQtjSP4PKAfuX7RdOclo");
    xhr.setRequestHeader("OuYeellAuthorization", "");
}
Http.get = function (suburl, callBack) {
    $.ajax({
        type: "GET",
        url: rootUrl + suburl,
        data: null,
        contentType: "application/json; charset=UTF-8",
        crossDomain: true,
        timeout: 20000,
        beforeSend: function (xhr) {
            // setHeader(xhr);
        },
        success: function (response, status, xhr) {
            callBack(true, response);
        },
        error: function (xhr) {
            responseJson = "";
            if (xhr.status == 400) {
                responseJson = xhr.responseJSON;
            }
            if (xhr.status == 0) {
                responseJson = {message: '01-网络连接错误'};
            }
            callBack(false, responseJson);
        }

    });
};


Http.post = function (suburl, data, callBack) {
    $.ajax({
        type: "POST",
        url: rootUrl + suburl,
        data: JSON.stringify(data),
        contentType: "application/json; charset=UTF-8",
        crossDomain: true,
        timeout: 20000,
        beforeSend: function (xhr) {
            // setHeader(xhr);
        },
        success: function (response, status, xhr) {
            callBack(true, response);
        },
        error: function (xhr) {
            responseJson = "";
            if (xhr.status == 400) {
                responseJson = xhr.responseJSON;
            }
            if (xhr.status == 0) {
                responseJson = {message: '01-网络连接错误'};
            }
            callBack(false, responseJson);
        }

    });
};